<template>
  <el-row class="cardbg">
    <el-card>
      <el-avatar :size="96" :src="blogInfo.avatar" fit="cover" class="user-avatar"></el-avatar>
      <div class="nickname">{{ blogInfo.nickname }}</div>
      <div class="info-box">
        <div class="text-center">
          <div class="info-count">{{ blogInfo.articleCount }}</div>
          <div class="info-desc">文章数</div>
        </div>
        <div class="text-center">
          <div class="info-count">{{ blogInfo.totalViews }}</div>
          <div class="info-desc">浏览量</div>
        </div>
      </div>
      <el-divider></el-divider>
      <i class="el-icon-menu">文章分类</i>
      <router-link
        :to="'/category/' + category.name"
        class="category-item"
        v-for="(category, index) in categories"
        :key="index"
      >
        {{ category.name }}
        <el-tag type="success" size="small" effect="dark">{{ category.count }}</el-tag>
      </router-link>
      <el-divider></el-divider>
      <i class="el-icon-price-tag">文章标签</i>
      <div class="tag-box">
        <router-link :to="'/tag/ + tag'" v-for="(tag, index) in tags" :key="index">
          <el-tag effect="plain" size="small">{{ tag }}</el-tag>
        </router-link>
      </div>
    </el-card>

    <el-card >
      <div class="blog-card">
        <i class="el-icon-s-opportunity"></i>
        公告
      </div>
      <div class="gg">
        <p>白内障看不清?</p>
        <p>硫酸兑水滴眼睛。</p>
        <p><a href="https://reganblog.club/" style="text-decoration: none">博客副站</a></p>
      </div>
      
    </el-card>

    <el-card>
      <div class="blog-card">
        <i class="el-icon-tickets"></i>
        网站资讯
      </div>
      <div class="gg">网站访问量：   {{ blogInfo.totalViews }}</div>
      <div class="gg">网站建站时间： 2023/3</div>
    </el-card>
  </el-row>
</template>

<script>
import request from "@/http/request";
import { mapState } from "vuex";

export default {
  name: "BlogInfo",
  data() {
    return {
      categories: [],
      tags: [],
    };
  },
  computed: mapState(["blogInfo"]),
  created() {
    request
      .getAllTags()
      .then((res) => {
        if (res.code === 0) {
          this.tags = res.data;
        } else {
          this.$notify.error({
            title: "提示",
            message: res.msg,
          });
        }
      })
      .catch((err) => {
        console.log(err);
        this.$notify.error({
          title: "提示",
          message: "网络繁忙，标签获取失败",
        });
      });

    request
      .getAllCategories()
      .then((res) => {
        if (res.code === 0) {
          this.categories = res.data;
        } else {
          this.$notify.error({
            title: "提示",
            message: res.msg,
          });
        }
      })
      .catch((err) => {
        console.log(err);
        this.$notify.error({
          title: "提示",
          message: "网络繁忙，文章分类获取失败",
        });
      });
  },
};
</script>

<style scoped>
.user-avatar{
  border-radius: 50%;
  transition: all 0.5s;
}
.user-avatar:hover{
  transform: rotate(360deg);
}
.el-avatar {
  display: block;
  margin: 0 auto;
}
.nickname {
  margin-top: 5px;
  color: #303133;
  font-size: 16px;
  text-align: center;
}
.info-box {
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.info-count {
  color: #303133;
  font-weight: bold;
  font-size: 20px;
}
.info-desc {
  color: #909399;
  font-size: 12px;
}
.category-item {
  display: block;
  text-decoration: none;
  font-size: 14px;
  color: #606266;
  margin-top: 10px;
  padding: 8px;
  transition: all 0.5s;
  border-radius: 5px;
  border: 1px solid #ebeef5;
}
.category-item:hover {
  box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 8px 0px;
  cursor: pointer;
  transform: scale(1.03);
  color: #303133;
}
.category-item .el-tag {
  float: right;
}
.tag-box {
  margin-top: 10px;
}
.tag-box .el-tag {
  margin: 0 2px;
}
.tag-box .el-tag:hover {
  background-color: #409eff;
  color: #ffffff;
  cursor: pointer;
}

.cardbg {
  /* background: radial-gradient(ellipse at top right,  #6190E8 10%,#fffeea  25%, #F2AA9D 30%); */
  border-radius: 3px;
  margin: 10px;
}
.el-card {
  margin-bottom: 20px;
  background-color: #eee;
  border-radius: 8px;
  opacity: 0.9;
}
.gg {
  margin: 12px;
  text-decoration: none;
}
.blog-card{
  font-size: 18px;
}
</style>
